package net.stratusprogramming.school.Game.Framework.Items;

import net.stratusprogramming.school.Game.Framework.Battle.Combatant;

/**
 * Represents a weapon that can be used to attack an enemy
 * 
 * @author Dominic Vitello, Patrick Lienau, Jeremy Pan
 * @serial 5/2/12
 * @version 0.1
 */
public class Weapon extends Item {
	
	/** The effect the weapon will have on the enemy */
	protected Effect effect;
	
	/**
	 * Creates a new Weapon
	 */
	public Weapon() {
		
	}
	
	/**
	 * Constructor for Weapon
	 * 
	 * @param name
	 * @param value
	 * @param weight
	 */
	public Weapon(String name, float value, float weight, Effect effect){
		super(name, value, weight);
		this.effect = effect;
	}
	
	/**
	 * Attacks an enemy
	 * 
	 * @param enemy to attack
	 * @param who is attacking (should be set to this)
	 * @return a string to print to the battle log
	 */
	public String attack(Combatant enemy, Combatant owner) {
		String log = effect.affect(enemy, owner);
		String ret = owner.getName()+" used "+name+" to attack "+enemy.getName();
		if(log.length() != 0) ret += " ["+log+"]";
		return ret;
	}
	
}
